//
//  CHPDFVViewController.swift
//  jyzx
//
//  Created by CY on 2024/10/31.
//

import UIKit
import QuickLook
@available(iOS 11.0, *)
public class CHPDFVViewController: UIViewController {
    
    let qlPreviewVC:QLPreviewController = QLPreviewController()
    
    let pdfView:PDFView? = PDFView()
    
    var fileUrls:[String]?
    var urls:[URL]?
    var datas:[Data]?
    var pdfViews: [PDFView] = []
    var navtitle:String?
    public init(fileUrls:[String]?,navtitle:String?){
        super.init(nibName: nil, bundle: nil)
        self.fileUrls = fileUrls
        self.navtitle = navtitle
    }
    public init(urls:[URL]?,navtitle:String?){
        super.init(nibName: nil, bundle: nil)
        self.urls = urls
        self.navtitle = navtitle
    }
    
    public init(datas:[Data]?,navtitle:String?){
        super.init(nibName: nil, bundle: nil)
        self.datas = datas
        self.navtitle = navtitle
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    public override func viewDidLoad() {
        super.viewDidLoad()

        self.navigationItem.title = self.navtitle
        self.view.addSubview(self.pdfColView)
        if self.fileUrls?.count ?? 0 > 0{
            self.pdfColView.refreshData(files: self.fileUrls)
        }
        
        if self.urls?.count ?? 0 > 0{
            self.pdfColView.refreshData(urls: self.urls)
        }
 
        if self.datas?.count ?? 0 > 0{
            self.pdfColView.refreshData(datas: self.datas)
        }
        
        self.pdfColView.snp.makeConstraints { make in
            make.left.equalTo(0)
            make.right.equalTo(0)
            make.top.equalTo(0)
            make.bottom.equalTo(0
            )
        }
    }
    
 

    

    
    lazy var pdfColView = {()-> CHPDFColView in
        let v:CHPDFColView = CHPDFColView()

        v.backgroundColor = UIColor.white
        return v;
    }()
  
}


